package org.example.wax.utils;

public class BytesUtils {

    public synchronized static byte[] hex2Bytes(String hex) {
        String h = hex.replace(" ", "");
        int length = h.length() / 2;
        byte[] data = new byte[length];
        String str1;
        int offset;
        int end;
        for (int i = 0; i < length; i++) {
            offset = i * 2 + 1;
            end = offset + 1;
            str1 = "0x" + h.substring(i * 2, offset) + h.substring(offset, end);
            try {
                data[i] = Integer.decode(str1).byteValue();
            } catch (Exception ex) {

            }
        }
        return data;
    }
}
